﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml
Public Class List_page
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        ' this is a code for search 

        If TextBox2.Text <> "" Then
            Dim cost As Integer
            Try

                ' Convert textbox to integer
                cost = Convert.ToInt32(TextBox2.Text)
            Catch ex As Exception
                cost = 0
            End Try

            Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\CruisesDB.accdb;Persist Security Info=True"
            Dim SqlString As String = "SELECT        CId, CTitle, CDate, CTime, CSeason, CCountry, CCity, CPlace, CCoste, CDescription, CThumbnail, Cuserid, CCreatedate         FROM CruisesTable  WHERE        (CTitle LIKE '%" & TextBox2.Text & "%') OR                          (CSeason LIKE '%" & TextBox2.Text & "%') OR                         (CCountry LIKE '%" & TextBox2.Text & "%') OR                          (CCity LIKE '%" & TextBox2.Text & "%') OR                          (CPlace LIKE '%" & TextBox2.Text & "%') OR                          (CCoste =" & cost & ")"

            SqlDataSourceCruisesTable.SelectCommand = SqlString
            'view search result in the gridview
            GridView2.DataBind()
        End If

    End Sub
End Class